package org.szy.plugin.dev.controller;


import com.mybatisflex.core.paginate.Page;
import org.noear.solon.annotation.*;
import org.noear.solon.core.handle.ModelAndView;
import org.noear.solon.validation.annotation.NoRepeatSubmit;
import org.noear.solon.validation.annotation.NotBlank;
import org.noear.solon.validation.annotation.NotNull;
import org.noear.solon.validation.annotation.Validated;
import org.szy.core.common.controller.BaseController;
import org.szy.core.common.param.CommonStatusParam;
import org.szy.core.common.entity.R;

import java.util.List;
import org.szy.plugin.dev.entity.DevLoginLog;
import org.szy.plugin.dev.param.DevLoginLogQueryParam;
import org.szy.plugin.dev.service.DevLoginLogService;

import java.util.List;

/**
 * 开发-登录日志控制器
 *
 * @author wangbuhao
 * @since 2023-06-28 18:17:40
 */
@Controller
@Mapping("/dev/loginLog")
public class DevLoginLogController extends BaseController<DevLoginLog> {

    private final String PATH_PREFIX = "dev/loginLog/";
    @Inject
    private DevLoginLogService devLoginLogService;

    /**
     * 开发-登录日志列表页面
     */
    @Get
    @Mapping("/index")
    public ModelAndView index() {
        ModelAndView view = new ModelAndView(PATH_PREFIX + "index");
        return view;
    }

    /**
     * 开发-登录日志编辑页
     */
    @Get
    @Mapping("/edit")
    public ModelAndView edit() {
        ModelAndView view = new ModelAndView(PATH_PREFIX + "edit");
        return view;
    }

    /**
     * 开发-登录日志详情页
     */
    @Get
    @Mapping("/detail")
    public ModelAndView detail() {
        ModelAndView view = new ModelAndView(PATH_PREFIX + "detail");
        return view;
    }

    /**
     * 获取开发-登录日志分页数据
     *
     * @author wangbuhao
     * @since 2023-06-28 18:17:40
     */
    @Get
    @Mapping("/page")
    public R<Page<DevLoginLog>> page(DevLoginLogQueryParam param) {
        return R.data(devLoginLogService.page(getPage(), param));
    }

    /**
     * 获取开发-登录日志详情
     *
     * @author wangbuhao
     * @since 2023-06-28 18:17:40
     */
    @Get
    @Mapping("/getInfo")
    public R<DevLoginLog> getInfo(@NotNull Long id) {
        return R.asNull(devLoginLogService.getById(id));
    }


    /**
     * 删除开发-登录日志
     *
     * @author wangbuhao
     * @since 2023-06-28 18:17:40
     */
    @Delete
    @Mapping("/delete")
    public R<?> delete(@NotNull Long id) {
        boolean delete = devLoginLogService.removeById(id);
        return R.bool(delete, "删除成功", "删除失败，数据可能正在使用或已删除");
    }

}
